﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using ArcEngine.Resources;
using System.Text;
using System.Windows.Forms;

namespace ArcEngine.Editor
{
	public partial class LevelPropertyForm : Form
	{
		public LevelPropertyForm(Level lvl)
		{
			Level = lvl;
			InitializeComponent();


			Init();
		}


		/// <summary>
		/// Init the form
		/// </summary>
		/// <param name="lvl">Level to edit</param>
		/// <returns></returns>
		public bool Init()
		{
			if (Level == null)
				return false;

			PropertyBox.SelectedObject = Level;
			LevelWidthLabel.Text = Level.Width.ToString();
			DesiredLevelWidth.Value = Level.Width;
			LevelHeightLabel.Text = Level.Height.ToString();
			DesiredLevelHeight.Value = Level.Height;

			BlockWidthLabel.Text = Level.BlockSize.Width.ToString();
			DesiredBlockWidth.Value = Level.BlockSize.Width;
			BlockHeightLabel.Text = Level.BlockSize.Height.ToString();
			DesiredBlockHeight.Value = Level.BlockSize.Height;
			return true;
		}



		#region Events

		/// <summary>
		/// Close the form
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OkButton_Click(object sender, EventArgs e)
		{
			Close();
		}

		/// <summary>
		/// Resize the level
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void ResizeButton_Click(object sender, EventArgs e)
		{
			Level.Resize(new Size((int)DesiredLevelWidth.Value, (int)DesiredLevelHeight.Value));
		}


		/// <summary>
		///  Resize blocks
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void ResizeBlockButton_Click(object sender, EventArgs e)
		{
			Level.BlockSize = new Size((int)DesiredBlockWidth.Value, (int)DesiredBlockHeight.Value);
		}



		#endregion


		#region Properties

		/// <summary>
		/// 
		/// </summary>
		Level Level;

		#endregion

	}
}
